#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    int n;
    cin>>n;
    vector<int> v(n+1);
    int mn=INT_MAX,mx=0,j=0,o=0;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
        if(v[i]%2)j++;
        else o++;
        mx=max(v[i],mx);
        mn=min(v[i],mn);
    }
    sort(v.begin()+1,v.end());
    int ans=0;
    if((mx%2+mn%2)%2==0)cout<<ans<<endl;
    else
    {
        while(1)
        {
            ans++;
            int x=v[ans]+v[n-ans],
            y=v[ans+1]+v[n-ans],
            z=v[ans+1]+v[n-ans+1];
            if(x%2==0||y%2==0||z%2==0)
            {
                cout<<ans<<endl;
                return ;
            }
        }
    }
}
signed main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int T=1;
    cin>>T;
    while(T--)
    {
       solve();
    }
    return 0;
}